package com.runmi.webchat.aftersale.web.api.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.runmi.webchat.aftersale.common.result.Result;
import com.runmi.webchat.aftersale.common.result.ResultFactory;
import com.runmi.webchat.aftersale.dbcore.entity.ShopInfo;
import com.runmi.webchat.aftersale.dbcore.entity.UserNote;
import com.runmi.webchat.aftersale.dbcore.mapper.UserNoteMapper;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@RequestMapping(value = "/webchatapi/note")
public class UserNoteController {

	@Autowired
	private UserNoteMapper userNoteMapper;
	
	
	  @ApiOperation(value = "提交意见反馈", notes = "提交意见反馈",tags={ "微信API", })
	  @RequestMapping(value = "/saveNote",method = RequestMethod.POST)
	  @ResponseBody
	  public Result saveNote(
	          @ApiParam(value = "店铺ID",required = true)@RequestParam(value = "shopId") Integer shopId,
	          @ApiParam(value = "openId",required = true)@RequestParam(value = "openId") String openId,
	          @ApiParam(value = "类型0:需求登记 1:投诉建议",required = true)@RequestParam(value = "noteType") Byte noteType,
	          @ApiParam(value = "客户姓名",required = true)@RequestParam(value = "customerName") String customerName,
	          @ApiParam(value = "投诉电话",required = true)@RequestParam(value = "mobile") String mobile,
	          @ApiParam(value = "说明或者服务要求",required = true)@RequestParam(value = "note") String note,
	          @ApiParam(value = "感兴趣商品",required = false)@RequestParam(value = "itemDesc",required = false) String itemDesc
	          ){		  
		  UserNote userNote=new UserNote();
		  userNote.setCreateTime(new Date());
		  userNote.setCustomerName(customerName);
		  userNote.setMobile(mobile);
		  userNote.setShopId(shopId);
		  userNote.setOpenId(openId);
		  userNote.setDelFlag((byte)0);
		  userNote.setStatus((byte)0);
		  userNote.setType(noteType);
		  userNote.setRemark(note);
		  userNote.setItemName(itemDesc);
		  userNoteMapper.insert(userNote);
	      return ResultFactory.getResultSuccess();
	  }
}
